﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Reflection;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using ToolkitMgtModule.DataEnum;
using CommonClass;

namespace ToolkitMgtModule.Converter
{
    #region String2StringConverter

    public class String2StringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            if (value != null && parameter is string)
            {
                switch (parameter as string)
                {
                    case "RecordFileType":
                        RecordFileTypeEnum outRecordFileType;
                        if (Enum.TryParse<RecordFileTypeEnum>(value.ToString(), true, out outRecordFileType))
                        {
                            return Utilities.GetEnumDisplayDescription(outRecordFileType);
                        }
                        break;


                    default:
                        return value.ToString();
                }
            }

            if (value != null)
                return value.ToString();
            else
                return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

    #endregion
}
